/*
 * strtool.c
 *
 *  Created on: Mar 5, 2024
 *      Author: DengZicheng
 */
/**
 * Copyright (c) 2024 Deng Zicheng
 *"BleSmartCar" is licensed under Mulan PSL v2.
 *You can use this software according to the terms and conditions of the Mulan PSL v2.
 *You may obtain a copy of Mulan PSL v2 at:
 *http://license.coscl.org.cn/MulanPSL2
 *THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *See the Mulan PSL v2 for more details.
 */
#include "strtool.h"


int substr(uint8_t * substring,uint8_t * string,int start,int n){
    int len = strlen((char *)string);
    if (len <= 0||start < 0 ) return 0;
    if (start > len-1) return 0;
    if (len < (start + n)) return 0;
    uint32_t i;
    for (i = 0; i < n; i++) {
        substring[i] = string[start + i];
    }
    substring[i] = 0;
    return 1;
}

int strIndex(char * string,int c){
	int i;
	for(i=0;i<strlen(string);i++){
		if(string[i]==c){
			break;
		}
	}
	return i;
}


